package to_hbase

import org.apache.hadoop.hbase.client.{Put, Table}
import org.apache.hadoop.hbase.util.Bytes

import scala.io.Source
import common.Utils
object Tyes_map01 {

  def putDatas(tableName:String,lines:Array[String])={
    val table:Table=Utils.curTable(tableName)
    for(line<-lines){
      try{
        val arr:Array[String]=line.split("\t")
        if(arr.length<4) println(1)
        val SourceCode=arr(1)
        val rowkey="IBRD_"+SourceCode
        val put:Put=new Put(Bytes.toBytes(rowkey))
        put.addColumn(Bytes.toBytes(arr(0)),Bytes.toBytes(arr(2)),Bytes.toBytes(arr(3)))//注释一
        table.put(put)
      }catch{
        case e: Exception => e.printStackTrace()
      }finally {
        table.close()
      }
    }
  }

  def main(args: Array[String]): Unit = {
    val path="/Users/kelisiduofu/Desktop/TEST_map0102types"
    val source=Source.fromFile(path,"utf-8")
    val lines=source.getLines().toArray
    source.close()
    val tableName="base" //BaseMapInfos
    putDatas(tableName,lines)
  }
}


/*
一.
addColumn(family: Array[Byte], qualifier: Array[Byte], value: Array[Byte])
("map01","ObjectId","_id")
("dealTypes","ObjectId","type01")
*/
